package com.wesley.spring;

import com.wesley.spring.entity.Car;
import com.wesley.spring.entity.Company;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * <p>
 *
 * </p>
 *
 * @author Created by Yani on 2020/07/09
 */
//@Configuration
@ComponentScan("com.wesley.spring")
public class AnnoEntrance {

    public static void main(String[] args) {
		AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
		applicationContext.register(AnnoEntrance.class);
		applicationContext.refresh();

        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for(String beanDefinitionName : beanDefinitionNames){
            System.out.println(beanDefinitionName);
        }

		Car car = applicationContext.getBean("car", Car.class);
		car.drive();
		Company company = applicationContext.getBean("company", Company.class);
		company.test();
		company.test();
//        welcomeController.handleRequest();
//        User user = (User)applicationContext.getBean("user05");
//        System.out.println(" ------> "+ user);
//
//        Car car1 = applicationContext.getBean(Car.class);
//        System.out.println(car1);
//		applicationContext.close();
    }

	/**
	 * 演示生命周期
	 */
//    @Bean(initMethod = "initMethod",destroyMethod = "destroyMethod")
//    public LifecycleBeanSample lifecycleBeanSample() {
//        return new LifecycleBeanSample();
//    }

}
